<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Log4j2 Manual - Apache Log4j 2 | Docs4dev</title>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback’s architecture.">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="HandheldFriendly" content="true">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta property="og:type" content="website">
<meta property="og:title" content="Log4j2 Manual - Apache Log4j 2">
<meta property="og:url" content="https://www.docs4dev.com/docs/en/log4j2/2.x/all/">
<meta property="og:site_name" content="Docs4dev">
<meta property="og:locale" content="zh_CN">
<meta name="twitter:card" content="Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback’s architecture.">
<meta name="generator" content="Docs4dev template engine">
<link rel="stylesheet" href="static/css/app.min.css">
<link rel="shortcut icon" href="https://www.docs4dev.com/static/images/favicon.ico" type="image/x-icon">
<script async="" src="static/js/js.js"></script>
<script async="" src="static/js/adsbygoogle.js" crossorigin="anonymous"></script>
<script>
    window.dataLayer = window.dataLayer || [];

    function gtag() {
      dataLayer.push(arguments);
    }

    gtag('js', new Date());
    gtag('config', 'UA-129571937-1');
  </script>
<link rel="amphtml" href="https://www.docs4dev.com/amp/docs/en/log4j2/2.x/all/index.html">

<script type="application/ld+json">{"name":null,"headline":"Log4j2 Manual-Apache Log4j 2","inLanguage":"en-US","version":"2.x","image":"/static/icon/icon-log4j2.png","datePublished":"2021-05-20T12:51:01Z","dateCreated":"2021-05-20T12:51:01Z","dateModified":"2021-07-07T12:38:40Z","@context":"https://schema.org/","@type":"APIReference","abstract":"Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback’s architecture."}</script>
</head>
<body>
<div class="book with-summary">
<div class="book-summary">
<div class="logo">
<a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all');" style="color: inherit;">
<img src="static/picture/icon-log4j2.png" style="width: 48px; height: 48px;" alt="Logo">
</a>
<b style="color: inherit; margin-left: 8px;">Log4j2 Manual</b>
</div>
<div class="item">
<div>
<label for="version">版本</label>
<select id="version" onchange="onVersionChange(this)">
<option value="2.x" selected="selected">2.x</option>
</select>
</div>
<div style="margin-top: 8px;">
<label for="language">语言</label>
<select id="language" onchange="onLangChange(this)" value="en">
<option value="en" selected="selected">English</option>
<option value="zh">中文</option>
</select>
</div>

</div>
<div class="item menus">
<a title="Table of Contents" style="margin-right: 8px;" href="#">
<i class="fa fa-chevron-left"></i>
<span style="margin-left: 2px;">返回目录</span>
</a>
</div>
<nav role="navigation" id="navigation">
<ul class="summary">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/index.html#');" title="Apache Log4j™ 2"> Apache Log4j™ 2 </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/index.html#');" title="About"> About </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/download.html');" title="Download"> Download </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/javadoc.html');" title="Javadoc"> Javadoc </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/2.x/log4j-api/apidocs/index.html');" title="Log4j 2 API"> Log4j 2 API </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/2.x/log4j-core/apidocs/index.html');" title="Implementation"> Implementation </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/2.x/log4j-taglib/apidocs/index.html');" title="JSP Tag Library"> JSP Tag Library </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/2.x/log4j-taglib/tlddoc/index.html');" title="JSP Tag Library (TLD Doc)"> JSP Tag Library (TLD Doc) </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/maven-artifacts.html');" title="Maven, Ivy, Gradle Artifacts"> Maven, Ivy, Gradle Artifacts </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/maven-artifacts.html#Using_Log4j_in_your_Apache_Maven_build');" title="Maven"> Maven </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/maven-artifacts.html#Using_Log4j_in_your_Apache_Ivy_build');" title="Ivy"> Ivy </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/maven-artifacts.html#Using_Log4j_in_your_Gradle_build');" title="Gradle"> Gradle </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/maven-artifacts.html#Using_Log4j_in_your_SBT_build');" title="SBT"> SBT </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/maven-artifacts.html#Bill_of_Material');" title="Bill of Material"> Bill of Material </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/maven-artifacts.html#Optional_Components');" title="Optional Components"> Optional Components </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/maven-artifacts.html#Snapshot_builds');" title="Snapshot builds"> Snapshot builds </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/runtime-dependencies.html');" title="Runtime Dependencies"> Runtime Dependencies </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/changelog.html');" title="Changelog"> Changelog </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/faq.html');" title="FAQ"> FAQ </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/performance.html');" title="Performance"> Performance </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/performance.html#benchmarks');" title="Benchmarks"> Benchmarks </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/performance.html#loglibComparison');" title="Logging Library Comparison"> Logging Library Comparison </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/performance.html#asyncLogging');" title="Async Logging Comparison"> Async Logging Comparison </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/performance.html#asyncLoggingResponseTime');" title="Async Logging Latency"> Async Logging Latency </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/performance.html#asyncLoggingWithParams');" title="Parameters"> Parameters </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/performance.html#asyncLoggingWithLocation');" title="Location"> Location </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/performance.html#fileLoggingComparison');" title="File Logging Comparison"> File Logging Comparison </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/performance.html#filtering');" title="Filtering Comparison"> Filtering Comparison </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/performance.html#tradeoffs');" title="Trade-offs"> Trade-offs </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/articles.html');" title="Articles and Tutorials"> Articles and Tutorials </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/security.html');" title="Security"> Security </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/support.html');" title="Support"> Support </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/thanks.html');" title="Thanks"> Thanks </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/build.html');" title="For Contributors"> For Contributors </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/build.html');" title="Building Log4j from Source"> Building Log4j from Source </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/guidelines.html');" title="Guidelines"> Guidelines </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/javastyle.html');" title="Style Guide"> Style Guide </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-index.html');" title="Manual"> Manual </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-index.html');" title="Introduction"> Introduction </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-architecture.html');" title="Architecture"> Architecture </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-compatibility.html');" title="Log4j 1.x Compatibility"> Log4j 1.x Compatibility </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-migration.html');" title="Log4j 1.x Migration"> Log4j 1.x Migration </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-api.html');" title="Java API"> Java API </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-logbuilder.html');" title="Log Builder"> Log Builder </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-flowtracing.html');" title="Flow Tracing"> Flow Tracing </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-markers.html');" title="Markers"> Markers </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-eventlogging.html');" title="Event Logging"> Event Logging </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-messages.html');" title="Messages"> Messages </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-thread-context.html');" title="ThreadContext"> ThreadContext </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-scala-api.html');" title="Scala API"> Scala API </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html');" title="Configuration"> Configuration </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#AutomaticConfiguration');" title="Automatic Configuration"> Automatic Configuration </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#Additivity');" title="Additivity"> Additivity </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#AutomaticReconfiguration');" title="Automatic Reconfiguration"> Automatic Reconfiguration </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#ChainsawSupport');" title="Chainsaw Support"> Chainsaw Support </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#ConfigurationSyntax');" title="Configuration Syntax"> Configuration Syntax </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#XML');" title="XML Syntax"> XML Syntax </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#JSON');" title="JSON Syntax"> JSON Syntax </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#YAML');" title="YAML Syntax"> YAML Syntax </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#Properties');" title="Properties Syntax"> Properties Syntax </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#Loggers');" title="Configuring Loggers"> Configuring Loggers </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#Appenders');" title="Configuring Appenders"> Configuring Appenders </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#Filters');" title="Configuring Filters"> Configuring Filters </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#PropertySubstitution');" title="Property Substitution"> Property Substitution </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#RuntimeLookup');" title="Lookup Variables"> Lookup Variables </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#Scripts');" title="Scripts"> Scripts </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#XInclude');" title="XInclude"> XInclude </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#CompositeConfiguration');" title="Composite Configurations"> Composite Configurations </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#StatusMessages');" title="Status Messages"> Status Messages </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#UnitTestingInMaven');" title="Unit Testing in Maven"> Unit Testing in Maven </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html#SystemProperties');" title="System Properties"> System Properties </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-usage.html');" title="Usage"> Usage </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-usage.html#StaticVsNonStatic');" title="Static vs non-Static Loggers"> Static vs non-Static Loggers </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-usage.html#LoggerVsClass');" title="Logger Name vs Class Name"> Logger Name vs Class Name </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-cloud.html');" title="Logging in the Cloud"> Logging in the Cloud </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-webapp.html');" title="Web Applications and JSPs"> Web Applications and JSPs </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-webapp.html#Servlet-3.0');" title="Servlet 3.0 and Newer"> Servlet 3.0 and Newer </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-webapp.html#Servlet-2.5');" title="Servlet 2.5"> Servlet 2.5 </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-webapp.html#ContextParams');" title="Context Parameters"> Context Parameters </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-webapp.html#WebLookup');" title="Configuration Lookups"> Configuration Lookups </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-webapp.html#JspLogging');" title="JavaServer Pages Logging"> JavaServer Pages Logging </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-webapp.html#Async');" title="Asynchronous Requests"> Asynchronous Requests </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html');" title="Lookups"> Lookups </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#ContextMapLookup');" title="Context Map"> Context Map </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#DateLookup');" title="Date"> Date </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#DockerLookup');" title="Docker"> Docker </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#EnvironmentLookup');" title="Environment"> Environment </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#EventLookup');" title="Event"> Event </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#JavaLookup');" title="Java"> Java </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#JndiLookup');" title="JNDI"> JNDI </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#JmxRuntimeInputArgumentsLookup');" title="JVM Arguments"> JVM Arguments </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#KubernetesLookup');" title="Kubernetes"> Kubernetes </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#Log4jConfigLookup');" title="Log4j Config"> Log4j Config </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#LowerLookup');" title="Lower"> Lower </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#AppMainArgsLookup');" title="Main Arguments"> Main Arguments </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#MapLookup');" title="Map"> Map </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#SpringLookup');" title="Spring"> Spring </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#StructuredDataLookup');" title="Structured Data"> Structured Data </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#SystemPropertiesLookup');" title="System Properties"> System Properties </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#UpperLookup');" title="Upper"> Upper </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html#WebLookup');" title="Web"> Web </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html');" title="Appenders"> Appenders </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#AsyncAppender');" title="Async"> Async </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#CassandraAppender');" title="Cassandra"> Cassandra </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#ConsoleAppender');" title="Console"> Console </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#FailoverAppender');" title="Failover"> Failover </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#FileAppender');" title="File"> File </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#FlumeAppender');" title="Flume"> Flume </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#JDBCAppender');" title="JDBC"> JDBC </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#JMSAppender');" title="JMS"> JMS </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#JPAAppender');" title="JPA"> JPA </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#HttpAppender');" title="HTTP"> HTTP </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#KafkaAppender');" title="Kafka"> Kafka </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#MemoryMappedFileAppender');" title="Memory Mapped File"> Memory Mapped File </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#NoSQLAppender');" title="NoSQL"> NoSQL </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#NoSQLAppenderMongoDB');" title="NoSQL for MongoDB"> NoSQL for MongoDB </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#NoSQLAppenderMongoDB2');" title="NoSQL for MongoDB 2"> NoSQL for MongoDB 2 </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#NoSQLAppenderMongoDB3');" title="NoSQL for MongoDB 3"> NoSQL for MongoDB 3 </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#NoSQLAppenderCouchDB');" title="NoSQL for CouchDB"> NoSQL for CouchDB </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#OutputStreamAppender');" title="Output Stream"> Output Stream </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#RandomAccessFileAppender');" title="Random Access File"> Random Access File </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#RewriteAppender');" title="Rewrite"> Rewrite </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#RollingFileAppender');" title="Rolling File"> Rolling File </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#RollingRandomAccessFileAppender');" title="Rolling Random Access File"> Rolling Random Access File </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#RoutingAppender');" title="Routing"> Routing </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#SMTPAppender');" title="SMTP"> SMTP </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#ScriptAppenderSelector');" title="ScriptAppenderSelector"> ScriptAppenderSelector </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#SocketAppender');" title="Socket"> Socket </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#SSL');" title="SSL"> SSL </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#SyslogAppender');" title="Syslog"> Syslog </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html#JeroMQAppender');" title="ZeroMQ/JeroMQ"> ZeroMQ/JeroMQ </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html');" title="Layouts"> Layouts </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html#CSVLayouts');" title="CSV"> CSV </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html#GELFLayout');" title="GELF"> GELF </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html#HTMLLayout');" title="HTML"> HTML </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html#JSONLayout');" title="JSON"> JSON </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html#PatternLayout');" title="Pattern"> Pattern </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html#RFC5424Layout');" title="RFC-5424"> RFC-5424 </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html#SerializedLayout');" title="Serialized"> Serialized </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html#SyslogLayout');" title="Syslog"> Syslog </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html#XMLLayout');" title="XML"> XML </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html#YamlLayout');" title="YAML"> YAML </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html#LocationInformation');" title="Location Information"> Location Information </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html');" title="Filters"> Filters </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html#BurstFilter');" title="Burst"> Burst </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html#CompositeFilter');" title="Composite Filter"> Composite Filter </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html#DynamicThresholdFilter');" title="Dynamic Threshold"> Dynamic Threshold </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html#MapFilter');" title="Map"> Map </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html#MarkerFilter');" title="Marker"> Marker </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html#RegexFilter');" title="Regex"> Regex </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html#Script');" title="Script"> Script </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html#StructuredDataFilter');" title="Structured Data"> Structured Data </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html#ThreadContextMapFilter');" title="Thread Context Map"> Thread Context Map </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html#ThresholdFilter');" title="Threshold"> Threshold </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html#TimeFilter');" title="Time"> Time </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-async.html');" title="Async Loggers"> Async Loggers </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-async.html#Trade-offs');" title="Trade-offs"> Trade-offs </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-async.html#AllAsync');" title="All Loggers Async"> All Loggers Async </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-async.html#MixedSync-Async');" title="Mixed Sync &amp; Async"> Mixed Sync &amp; Async </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-async.html#Location');" title="Location"> Location </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-async.html#Performance');" title="Performance"> Performance </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-async.html#UnderTheHood');" title="Under The Hood"> Under The Hood </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-garbagefree.html');" title="Garbage-free Logging"> Garbage-free Logging </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-garbagefree.html#Config');" title="Configuration"> Configuration </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-garbagefree.html#Appenders');" title="Supported Appenders"> Supported Appenders </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-garbagefree.html#Layouts');" title="Supported Layouts"> Supported Layouts </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-garbagefree.html#Filters');" title="Supported Filters"> Supported Filters </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-garbagefree.html#api');" title="API Changes"> API Changes </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-garbagefree.html#codeImpact');" title="Impact on Application Code"> Impact on Application Code </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-garbagefree.html#Performance');" title="Performance"> Performance </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-garbagefree.html#UnderTheHood');" title="Under the Hood"> Under the Hood </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-jmx.html');" title="JMX"> JMX </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-logsep.html');" title="Logging Separation"> Logging Separation </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html');" title="Extending Log4j"> Extending Log4j </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#LoggerContextFactory');" title="LoggerContextFactory"> LoggerContextFactory </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#ContextSelector');" title="ContextSelector"> ContextSelector </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#ConfigurationFactory');" title="ConfigurationFactory"> ConfigurationFactory </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#LoggerConfig');" title="LoggerConfig"> LoggerConfig </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#LogEventFactory');" title="LogEventFactory"> LogEventFactory </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#MessageFactory');" title="MessageFactory"> MessageFactory </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#Lookups');" title="Lookups"> Lookups </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#Filters');" title="Filters"> Filters </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#Appenders');" title="Appenders"> Appenders </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#Layouts');" title="Layouts"> Layouts </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#PatternConverters');" title="PatternConverters"> PatternConverters </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#Plugin_Builders');" title="Plugin Builders"> Plugin Builders </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#ContextDataProvider');" title="Custom ContextDataProvider"> Custom ContextDataProvider </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html#Custom_Plugins');" title="Custom Plugins"> Custom Plugins </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-plugins.html');" title="Plugins"> Plugins </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-plugins.html#Core');" title="Core"> Core </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-plugins.html#Converters');" title="Converters"> Converters </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-plugins.html#KeyProviders');" title="Key Providers"> Key Providers </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-plugins.html#Lookups');" title="Lookups"> Lookups </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-plugins.html#TypeConverters');" title="Type Converters"> Type Converters </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-plugins.html#DeveloperNotes');" title="Developer Notes"> Developer Notes </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customconfig.html');" title="Programmatic Log4j Configuration"> Programmatic Log4j Configuration </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customconfig.html#ConfigurationBuilder');" title="ConfigurationBuilder API"> ConfigurationBuilder API </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customconfig.html#ConfigurationFactory');" title="Understanding ConfigurationFactory"> Understanding ConfigurationFactory </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customconfig.html#Example');" title="Example"> Example </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customconfig.html#Configurator');" title="Using Configurator"> Using Configurator </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customconfig.html#Hybrid');" title="Config File and Code"> Config File and Code </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customconfig.html#AddingToCurrent');" title="After Initialization"> After Initialization </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customconfig.html#AppendingToWritersAndOutputStreams');" title="Appending to Writers &amp; OutputStreams"> Appending to Writers &amp; OutputStreams </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customloglevels.html');" title="Custom Log Levels"> Custom Log Levels </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customloglevels.html#DefiningLevelsInCode');" title="In Code"> In Code </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customloglevels.html#DefiningLevelsInConfiguration');" title="In Configuration"> In Configuration </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customloglevels.html#AddingOrReplacingLevels');" title="Adding or Replacing Levels"> Adding or Replacing Levels </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customloglevels.html#CustomLoggers');" title="Custom Loggers"> Custom Loggers </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customloglevels.html#ExampleUsage');" title="Custom Logger Example"> Custom Logger Example </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customloglevels.html#CodeGen');" title="Code Generation Tool"> Code Generation Tool </a> </li>
</ul> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/scala/index.html');" title="Related Projects"> Related Projects </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/scala/index.html');" title="Log4j-Scala"> Log4j-Scala </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/1.2/');" title="Legacy Sites"> Legacy Sites </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/1.2/');" title="Log4j 1.2 - End of Life"> Log4j 1.2 - End of Life </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/log4j-2.3/');" title="Log4j 2.3 - Java 6"> Log4j 2.3 - Java 6 </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/log4j-2.12.1');" title="Log4j 2.12.1 - Java 7"> Log4j 2.12.1 - Java 7 </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/2.x/log4j-api/index.html');" title="Components"> Components </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/2.x/log4j-api/index.html');" title="API"> API </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-core-index.html');" title="Implementation"> Implementation </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-jcl-index.html');" title="Commons Logging Bridge"> Commons Logging Bridge </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-1.2-api-index.html');" title="Log4j 1.2 API"> Log4j 1.2 API </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-slf4j-impl-index.html');" title="SLF4J Binding"> SLF4J Binding </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-jul-index.html');" title="JUL Adapter"> JUL Adapter </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-jpl-index.html');" title="JDK Platform Logger"> JDK Platform Logger </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-to-slf4j-index.html');" title="Log4j 2 to SLF4J Adapter"> Log4j 2 to SLF4J Adapter </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-flume-ng-index.html');" title="Apache Flume Appender"> Apache Flume Appender </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://logging.apache.org/log4j/2.x/log4j-taglib/index.html');" title="Log4j Tag Library"> Log4j Tag Library </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-jmx-gui-index.html');" title="Log4j JMX GUI"> Log4j JMX GUI </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-web-index.html');" title="Log4j Web Application Support"> Log4j Web Application Support </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-appserver-index.html');" title="Log4j Application Server Integration"> Log4j Application Server Integration </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-couchdb-index.html');" title="Log4j CouchDB appender"> Log4j CouchDB appender </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-mongodb2-index.html');" title="Log4j MongoDB2 appender"> Log4j MongoDB2 appender </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-mongodb3-index.html');" title="Log4j MongoDB3 appender"> Log4j MongoDB3 appender </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-cassandra-index.html');" title="Log4j Cassandra appender"> Log4j Cassandra appender </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-iostreams-index.html');" title="Log4j IO Streams"> Log4j IO Streams </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-liquibase-index.html');" title="Log4j Liquibase Binding"> Log4j Liquibase Binding </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-docker-index.html');" title="Log4j Docker Support"> Log4j Docker Support </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-spring-cloud-config-log4j-spring-cloud-config-client-index.html');" title="Log4j Spring Cloud Config Client"> Log4j Spring Cloud Config Client </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/dependency-convergence.html');" title="Project Information"> Project Information </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/dependency-convergence.html');" title="Dependency Convergence"> Dependency Convergence </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/dependency-management.html');" title="Dependency Management"> Dependency Management </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/team-list.html');" title="Project Team"> Project Team </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/mail-lists.html');" title="Mailing Lists"> Mailing Lists </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/issue-tracking.html');" title="Issue Tracking"> Issue Tracking </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/license.html');" title="Project License"> Project License </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/source-repository.html');" title="Source Repository"> Source Repository </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/project-summary.html');" title="Project Summary"> Project Summary </a> </li>
</ul> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/changes-report.html');" title="Project Reports"> Project Reports </a>
<ul class="articles">
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/changes-report.html');" title="Changes Report"> Changes Report </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/jira-report.html');" title="JIRA Report"> JIRA Report </a> </li>
<li class="chapter"> <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/rat-report.html');" title="RAT Report"> RAT Report </a> </li>
</ul> </li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<header class="book-header">
<div class="dropdown pull-right js-toolbar-action">
<a class="btn toggle-dropdown" aria-label="Language" href="#">
<i class="fa fa-globe"></i>
</a>
<div class="dropdown-menu dropdown-left">
<div class="dropdown-caret"><span class="caret-outer"></span><span class="caret-inner"></span></div>
<div class="buttons">
<button class="button size-1" onclick="changeLang('zh_CN')">中文</button>
</div>
<div class="buttons">
<button class="button size-1" onclick="changeLang('en_US')">English</button>
</div>
</div>
</div>
<a class="btn pull-right js-toolbar-action non-mobile" aria-label="Sign up" href="register.html">
<i class="fa fa-sign-in"></i> <span>注册</span>
</a>
<a class="btn pull-right js-toolbar-action non-mobile" aria-label="Sign in" href="register.html">
<i class="fa fa-sign-in"></i>
<span>登录</span>
</a>
<a class="btn pull-left js-toolbar-action btn-summary" href="#"><i class="fa fa-align-justify"></i></a>
<div class="dropdown pull-left font-settings js-toolbar-action">
<a class="btn toggle-dropdown" aria-label="Font Settings" href="#">
<i class="fa fa-font"></i>
</a>
<div class="dropdown-menu dropdown-right">
<div class="dropdown-caret"><span class="caret-outer"></span><span class="caret-inner"></span></div>
<div class="buttons">
<button class="button size-2 font-reduce">A</button>
<button class="button size-2 font-enlarge">A</button>
</div>
<div class="buttons">
<button class="button size-2 family-serif">Serif</button>
<button class="button size-2 family-sans">Sans</button>
</div>
<div class="buttons">
<button class="button size-3 theme-white">White</button>
<button class="button size-3 theme-sepia">Sepia</button>
<button class="button size-3 theme-night">Night</button>
</div>
</div>
</div>
<a class="btn pull-left js-toolbar-action non-mobile" aria-label="Home" href="en.html">
<i class="fa fa-home"></i> <span>首页</span>
</a>
<a class="btn pull-left js-toolbar-action non-mobile" aria-label="Guide" href="javascript:window.open('https://www.javadoc.org/');">
<i class="fa fa-book"></i> <span>API Docs</span>
</a>
<a class="btn pull-left js-toolbar-action non-mobile" aria-label="Tools" href="index37.html">
<i class="fa fa-gears"></i> <span>工具</span>
</a>
<div class="dropdown pull-left js-toolbar-action mobile">
<a class="btn toggle-dropdown" aria-label="Language" href="#">
<i class="fa fa-chevron-down"></i>
</a>
<div class="dropdown-menu dropdown-right">
<div class="dropdown-caret"><span class="caret-outer"></span><span class="caret-inner"></span></div>
<div class="buttons">
<a class="button size-1" aria-label="Home" href="en.html">
<i class="fa fa-home"></i> <span>首页</span>
</a>
</div>
<div class="buttons">
<a class="button size-1" aria-label="Guide" href="javascript:window.open('https://www.javadoc.org/');">
<i class="fa fa-book"></i> <span>API Docs</span>
</a>
</div>
<div class="buttons">
<a class="button size-1" aria-label="Tools" href="index37.html">
<i class="fa fa-gears"></i> <span>工具</span>
</a>
</div>
</div>
</div>
<div id="autocomplete" class="pull-right"></div>
<span id="toolbar-title"></span>
</header>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal markdown-section">
<div id="content">
<h1>Apache Log4j 2</h1>
<div><ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-6108808167664152" data-ad-slot="6964403648"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></div>
<div>

<p>Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback’s architecture.</p>

<nav>
<ul>
<li> Apache Log4j™ 2</li>
<li><a href="#"><span></span>About</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/download.html');" title="Download"><span></span>Download</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/javadoc.html');" title="Javadoc"><span></span>Javadoc</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/maven-artifacts.html');" title="Maven, Ivy, Gradle Artifacts"><span></span>Maven, Ivy, Gradle Artifacts</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/runtime-dependencies.html');" title="Runtime Dependencies"><span></span>Runtime Dependencies</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/changelog.html');" title="Changelog"><span></span>Changelog</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/faq.html');" title="FAQ"><span></span>FAQ</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/performance.html');" title="Performance"><span></span>Performance</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/articles.html');" title="Articles and Tutorials"><span></span>Articles and Tutorials</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/security.html');" title="Security"><span></span>Security</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/support.html');" title="Support"><span></span>Support</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/thanks.html');" title="Thanks"><span></span>Thanks</a></li>
<li> For Contributors</li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/build.html');" title="Building Log4j from Source"><span></span>Building Log4j from Source</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/guidelines.html');" title="Guidelines"><span></span>Guidelines</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/javastyle.html');" title="Style Guide"><span></span>Style Guide</a></li>
<li> Manual</li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-index.html');" title="Introduction"><span></span>Introduction</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-architecture.html');" title="Architecture"><span></span>Architecture</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-compatibility.html');" title="Log4j 1.x Compatibility"><span></span>Log4j 1.x Compatibility</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-migration.html');" title="Log4j 1.x Migration"><span></span>Log4j 1.x Migration</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-api.html');" title="Java API"><span></span>Java API</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-scala-api.html');" title="Scala API"><span></span>Scala API</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-configuration.html');" title="Configuration"><span></span>Configuration</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-usage.html');" title="Usage"><span></span>Usage</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-webapp.html');" title="Web Applications and JSPs"><span></span>Web Applications and JSPs</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html');" title="Lookups"><span></span>Lookups</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-appenders.html');" title="Appenders"><span></span>Appenders</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-layouts.html');" title="Layouts"><span></span>Layouts</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-filters.html');" title="Filters"><span></span>Filters</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-async.html');" title="Async Loggers"><span></span>Async Loggers</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-garbagefree.html');" title="Garbage-free Logging"><span></span>Garbage-free Logging</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-jmx.html');" title="JMX"><span></span>JMX</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-logsep.html');" title="Logging Separation"><span></span>Logging Separation</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-extending.html');" title="Extending Log4j"><span></span>Extending Log4j</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-plugins.html');" title="Plugins"><span></span>Plugins</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customconfig.html');" title="Programmatic Log4j Configuration"><span></span>Programmatic Log4j Configuration</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customloglevels.html');" title="Custom Log Levels"><span></span>Custom Log Levels</a> </li>
<li> Related Projects</li>
<li><a href="javascript:window.open('https://logging.apache.org/log4j/scala/index.html');" title="Log4j-Scala" target="_blank" rel="noopener noreferrer"><span></span>Log4j-Scala <i class="fa fa-external-link"></i></a></li>
<li> Legacy Sites</li>
<li><a href="javascript:window.open('https://logging.apache.org/log4j/1.2/');" title="Log4j 1.2 - End of Life" target="_blank" rel="noopener noreferrer"><span></span>Log4j 1.2 - End of Life <i class="fa fa-external-link"></i></a> </li>
<li><a href="javascript:window.open('https://logging.apache.org/log4j/log4j-2.3/');" title="Log4j 2.3 - Java 6" target="_blank" rel="noopener noreferrer"><span></span>Log4j 2.3 - Java 6 <i class="fa fa-external-link"></i></a></li>
<li><a href="javascript:window.open('https://logging.apache.org/log4j/log4j-2.12.1');" title="Log4j 2.12.1 - Java 7" target="_blank" rel="noopener noreferrer"><span></span>Log4j 2.12.1 - Java 7 <i class="fa fa-external-link"></i></a></li>
<li> Components</li>
<li><a href="javascript:window.open('https://logging.apache.org/log4j/2.x/log4j-api/index.html');" title="API" target="_blank" rel="noopener noreferrer"><span></span>API <i class="fa fa-external-link"></i></a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-core-index.html');" title="Implementation"><span></span>Implementation</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-jcl-index.html');" title="Commons Logging Bridge"><span></span>Commons Logging Bridge</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-1.2-api-index.html');" title="Log4j 1.2 API"><span></span>Log4j 1.2 API</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-slf4j-impl-index.html');" title="SLF4J Binding"><span></span>SLF4J Binding</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-jul-index.html');" title="JUL Adapter"><span></span>JUL Adapter</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-jpl-index.html');" title="JDK Platform Logger"><span></span>JDK Platform Logger</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-to-slf4j-index.html');" title="Log4j 2 to SLF4J Adapter"><span></span>Log4j 2 to SLF4J Adapter</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-flume-ng-index.html');" title="Apache Flume Appender"><span></span>Apache Flume Appender</a></li>
<li><a href="javascript:window.open('https://logging.apache.org/log4j/2.x/log4j-taglib/index.html');" title="Log4j Tag Library" target="_blank" rel="noopener noreferrer"><span></span>Log4j Tag Library <i class="fa fa-external-link"></i></a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-jmx-gui-index.html');" title="Log4j JMX GUI"><span></span>Log4j JMX GUI</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-web-index.html');" title="Log4j Web Application Support"><span></span>Log4j Web Application Support</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-appserver-index.html');" title="Log4j Application Server Integration"><span></span>Log4j Application Server Integration</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-couchdb-index.html');" title="Log4j CouchDB appender"><span></span>Log4j CouchDB appender</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-mongodb2-index.html');" title="Log4j MongoDB2 appender"><span></span>Log4j MongoDB2 appender</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-mongodb3-index.html');" title="Log4j MongoDB3 appender"><span></span>Log4j MongoDB3 appender</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-cassandra-index.html');" title="Log4j Cassandra appender"><span></span>Log4j Cassandra appender</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-iostreams-index.html');" title="Log4j IO Streams"><span></span>Log4j IO Streams</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-liquibase-index.html');" title="Log4j Liquibase Binding"><span></span>Log4j Liquibase Binding</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-docker-index.html');" title="Log4j Docker Support"><span></span>Log4j Docker Support</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/log4j-spring-cloud-config-log4j-spring-cloud-config-client-index.html');" title="Log4j Spring Cloud Config Client"><span></span>Log4j Spring Cloud Config Client</a></li>
<li> Project Information</li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/dependency-convergence.html');" title="Dependency Convergence"><span></span>Dependency Convergence</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/dependency-management.html');" title="Dependency Management"><span></span>Dependency Management</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/team-list.html');" title="Project Team"><span></span>Project Team</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/mail-lists.html');" title="Mailing Lists"><span></span>Mailing Lists</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/issue-tracking.html');" title="Issue Tracking"><span></span>Issue Tracking</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/license.html');" title="Project License"><span></span>Project License</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/source-repository.html');" title="Source Repository"><span></span>Source Repository</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/project-summary.html');" title="Project Summary"><span></span>Project Summary</a></li>
<li> Project Reports</li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/changes-report.html');" title="Changes Report"><span></span>Changes Report</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/jira-report.html');" title="JIRA Report"><span></span>JIRA Report</a> </li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/rat-report.html');" title="RAT Report"><span></span>RAT Report</a></li>
</ul>
</nav>

<section>
<h2 id="Features"><a name="Features"></a>Features</h2>
<section>
<h3 id="API-Separation"><a name="API_Separation"></a>API Separation</h3>
<p>The API for Log4j is separate from the implementation making it clear for application developers which classes and methods they can use while ensuring forward compatibility. This allows the Log4j team to improve the implementation safely and in a compatible manner.</p>
<p>The Log4j API is a logging facade that may, of course, be used with the Log4j implementation, but may also be used in front of other logging implementations such as Logback. The Log4j API has several advantages over SLF4J: 1. The Log4j API supports logging <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-messages.html');">Messages</a> instead of just Strings. 2. The Log4j API supports lambda expressions. 3. The Log4j API provides many more logging methods than SLF4J. 4. In addition to the “parameterized logging” format supported by SLF4J, the Log4j API also supports events using the java.text.MessageFormat syntax as well printf-style messages. 5. The Log4j API provides a LogManager.shutdown() method. The underlying logging implementation must implement the Terminable interface for the method to have effect. 6. Other constructs such as Markers, log Levels, and ThreadContext (aka MDC) are fully supported.</p>
</section>
<section>
<h3 id="Improved-Performance"><a name="Improved_Performance"></a>Improved Performance</h3>
<p>Log4j 2 contains next-generation Asynchronous Loggers based on the LMAX Disruptor library. In multi-threaded scenarios Asynchronous Loggers have 18 times higher throughput and orders of magnitude lower latency than Log4j 1.x and Logback. See <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-async.html#Performance');">Asynchronous Logging Performance</a> for details. Otherwise, Log4j 2 significantly outperforms Log4j 1.x, Logback and java.util.logging, especially in multi-threaded applications. See <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/performance.html');">Performance</a> for more information.</p>
</section>
<section>
<h3 id="Support-for-multiple-APIs"><a name="Support_for_multiple_APIs"></a>Support for multiple APIs</h3>
<p>While the Log4j 2 API will provide the best performance, Log4j 2 provides support for the Log4j 1.2, SLF4J, Commons Logging and java.util.logging (JUL) APIs.</p>
</section>
<section>
<h3 id="Avoid-lock-in"><a name="Avoid_lock-in"></a>Avoid lock-in</h3>
<p>Applications coded to the Log4j 2 API always have the option to use any SLF4J-compliant library as their logger implementation with the log4j-to-slf4j adapter.</p>
</section>
<section>
<h3 id="Automatic-Reloading-of-Configurations"><a name="Automatic_Reloading_of_Configurations"></a>Automatic Reloading of Configurations </h3>
<p>Like Logback, Log4j 2 can automatically reload its configuration upon modification. Unlike Logback, it will do so without losing log events while reconfiguration is taking place.</p>
</section>
<section>
<h3 id="Advanced-Filtering"><a name="Advanced_Filtering"></a>Advanced Filtering</h3>
<p>Like Logback, Log4j 2 supports filtering based on context data, markers, regular expressions, and other components in the Log event. Filtering can be specified to apply to all events before being passed to Loggers or as they pass through Appenders. In addition, filters can also be associated with Loggers. Unlike Logback, you can use a common Filter class in any of these circumstances.</p>
</section>
<section>
<h3 id="Plugin-Architecture"><a name="Plugin_Architecture"></a>Plugin Architecture</h3>
<p>Log4j uses the plugin pattern to configure components. As such, you do not need to write code to create and configure an Appender, Layout, Pattern Converter, and so on. Log4j automatically recognizes plugins and uses them when a configuration references them.</p>
</section>
<section>
<h3 id="Property-Support"><a name="Property_Support"></a>Property Support</h3>
<p>You can reference properties in a configuration, Log4j will directly replace them, or Log4j will pass them to an underlying component that will dynamically resolve them. Properties come from values defined in the configuration file, system properties, environment variables, the ThreadContext Map, and data present in the event. Users can further customize the property providers by adding their own <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-lookups.html');">Lookup</a> Plugin. </p>
</section>
<section>
<h3 id="Java-8-Lambda-Support"><a name="Java_8_Lambda_Support"></a>Java 8 Lambda Support</h3>
<p>Previously, if a log message was expensive to construct, you would often explicitly check if the requested log level is enabled before constructing the message. Client code running on Java 8 can benefit from Log4j’s <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-api.html#LambdaSupport');">lambda support</a>. Since Log4j will not evaluate a lambda expression if the requested log level is not enabled, the same effect can be achieved with less code.</p>
</section>
<section>
<h3 id="Custom-Log-Levels"><a name="Custom_Log_Levels"></a>Custom Log Levels</h3>
<p>In Log4j 2, <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-customloglevels.html');">custom log levels</a> can easily be defined in code or in configuration. No subclassing is required.</p>
</section>
<section>
<h3 id="Log-Builder-API"><a name="Log_Builder_API"></a>Log Builder API</h3>
<p>In addition to using one of the many log methods in the Log4j API, log events can be constructed using a builder. See [Log Builder][manual/logbuilder.html] for more information. </p>
</section>
<section>
<h3 id="Garbage-free"><a name="Garbage-free"></a>Garbage-free</h3>
<p>During steady state logging, Log4j 2 is <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-garbagefree.html');">garbage-free</a> in stand-alone applications, and low garbage in web applications. This reduces pressure on the garbage collector and can give better response time performance.</p>
</section>
<section>
<h3 id="Integrating-with-Application-Servers"><a name="Integrating_with_Application_Servers"></a>Integrating with Application Servers</h3>
<p>Version 2.10.0 added the module log4j-appserver to improve integration with Apache Tomcat and Eclipse Jetty.</p>
</section>
<section>
<h3 id="Cloud-Enabled"><a name="Cloud_Enabled"></a>Cloud Enabled</h3>
<p>Version 2.12.0 introduced support for accessing Docker container information via a Lookup and for accessing and updating the Log4j configuration through Spring Cloud Configuration. This support was enhanced in version 2.13.0 to add support for accessing Spring Boot properties as well as Kubernetes information. See <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-cloud.html');">Logging in the Cloud</a> for details.</p>
</section>
<section>
<h3 id="Compatible-with-Log4j-1.x"><a name="Compatible_with_Log4j_1.x"></a>Compatible with Log4j 1.x</h3>
<p>The Log4j-1.2-api module of Log4j 2 provides compatiblity for applications using the Log4j 1 logging methods. As of Log4j 2.13.0 Log4j 2 also provides experimental support for Log4j 1.x configuration files. See <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-compatibility.html');">Log4j 2 Compatiblity with Log4j 1</a> for more information.</p>
</section>
</section>
<section>
<h2 id="Documentation"><a name="Documentation"></a>Documentation</h2>
<p>The Log4j 2 User’s Guide is available on this <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/manual-index.html');">site</a> or as a downloadable <a href="static/file/log4j-users-guide.pdf" target="_blank" rel="noopener noreferrer">PDF <i class="fa fa-external-link"></i></a>.</p>
</section>
<section>
<h2 id="Requirements"><a name="Requirements"></a>Requirements</h2>
<p>Log4j 2.13.0 and greater require Java 8. Version 2.4 through 2.12.1 required Java 7 and versions 2.0-alpha1 to 2.3 required Java 6. Some features require optional dependencies; the documentation for these features specifies the dependencies.</p>
</section>
<section>
<h2 id="News"><a name="News"></a>News</h2>
<p>Log4j 2.13.3 is now available for production. The API for Log4j 2 is not compatible with Log4j 1.x, however an adapter is available to allow applications to continue to use the Log4j 1.x API. Adapters are also available for Apache Commons Logging, SLF4J, and java.util.logging.</p>
<p>Log4j 2.13.3 is the latest release of Log4j. As of Log4j 2.13.0 Log4j 2 requires Java 8 or greater at runtime. This release contains new features and fixes which can be found in the latest <a href="javascript:window.open('https://www.docs4dev.com/docs/en/log4j2/2.x/all/changes-report.html#a2.13.3');">changes report</a>.</p>
<p>Note that subsequent to the release of Log4j 2.6 a minor source incompatibility with prior release was found due to the addition of new methods to the Logger interface. If you have code that does:</p>
<div>
<div>
<pre class="source notranslate">logger.error(null, "This is the log message", throwable);
</pre>
</div>
</div>
<p>or similar with any log level you will get a compiler error saying the reference is ambiguous. To correct this either do:</p>
<div>
<div>
<pre class="source notranslate">logger.error("This is the log message", throwable);
</pre>
</div>
</div>
<p>or</p>
<div>
<div>
<pre class="source notranslate">logger.error((Marker) null, "This is the log message", throwable);
</pre>
</div>
</div>
<p>Log4j 2.13.3 maintains binary compatibility with previous releases.</p>
</section></div>
</div>
</section>
<div class="right-sidebar">
<div class="affix"><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6108808167664152" data-ad-slot="3102929424" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script></div>
</div>
</div>
<div class="ft">
<a href="#toolbar-title" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a>
<footer class="footer">
<div class="footer__container--normal">
<img alt="扫码关注公众号" title="扫码关注公众号" src="static/picture/qr-code.png" width="170" height="170">
<div class="footer__description--normal">
<p class="paragraph footer__author--normal">Docs4dev<sup class="super">&#xAE;</sup>
</p>
<p class="paragraph footer__quote&#45;&#45;normal">
如果你在使用过程中遇到任何问题，可以在 <a href="javascript:window.open('https://github.com/docs4dev/docs4dev-issues');" target="_blank" rel="noopener noreferrer">这里<i class="fa fa-external-link"></i></a> 提issue。
</p>
<div class="footer__main--normal">
<p class="paragraph footer__main__paragraph--normal copyright" style="color: #666 !important;">
<a href="javascript:window.open('https://beian.miit.gov.cn/');">
蜀ICP备14021783号-6
</a>
</p>
<p class="paragraph footer__main__paragraph--normal copyright" style="color: #666 !important;">
Copyright &#xA9; Docs4dev all
right reserved, powered by <a href="index2.html" target="_blank">Docs4dev</a></p>
</div>
</div>
</div>
<div class="box__issues">
</div>
</footer>
</div>
</div>
</div>
</div>
</div>
<script>
  var hasToc = true;
  /*  var downloadable = /!*false*!/ false;
    var editable = /!*false*!/ false;
    var code = /!*"log4j2"*!/ false;
    var version = /!*"2.x"*!/ false;
    var type = /!*"all"*!/ false;
    var lang = /!*"en"*!/ 'en';
    //edit link
    require(["gitbook", "jQuery"], function (gitbook, $) {
      gitbook.events.bind('start', function (e, config) {
        // Add edit toolbar to left
        var chapterId = /!*17209*!/ 0;
        if (downloadable) {
          gitbook.toolbar.createButton({
            icon: 'fa fa-download',
            text: '下载',
            onClick: function () {
              window.open('/download?code=' + code + '&version=' + version + '&type=' + type + '&lang=' + lang);
            }
          });
        }
        if (editable) {
          gitbook.toolbar.createButton({
            icon: 'fa fa-edit',
            text: '编辑此页',
            onClick: function () {
              window.open('/docs/edit?chapterId=' + chapterId + '&lang=' + lang);
            }
          });
        }
      });
    });*/
</script>
<script>
    var code = "log4j2";
    var lang = "en";
  </script>

<script src="static/js/autocomplete-js.js"></script>
<script src="static/js/app.min.js"></script>
<script src="static/js/search.min.js"></script>
</body>
</html>
